package com.sz.app.oss.api.common.contract;

import com.google.common.collect.Lists;
import com.sz.biz.common.contract.service.ServiceTypeEnum;
import com.sz.biz.common.contract.dto.ContServiceTypeDto;
import com.sz.common.base.dto.ResultDto;
import com.sz.common.base.exception.BizException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Function: 合同-公共数据controller
 * Author: yanhong.xiao.<br>
 * Date: 2017-07-20 14:05:00.
 */
@RestController
@RequestMapping("${api}/contracts/contract-common")
@Api(description = " ", tags = "105-001，合同-合同基础数据")
public class ContController {
    @ApiOperation(value = "获取合同的业务类型", notes = "获取合同的业务类型")
    @RequestMapping(value = "/serviceTypes", method = {RequestMethod.GET})
    @ResponseBody
    public ResultDto getTradeServiceTypes() throws BizException {
        ResultDto resultDto = new ResultDto();
        List<ContServiceTypeDto> dtoList = Lists.newArrayList();
        ServiceTypeEnum[] types = ServiceTypeEnum.values();
        for (ServiceTypeEnum type :
                types) {
            ContServiceTypeDto dto = new ContServiceTypeDto();
            dto.setCode(ServiceTypeEnum.getIntegerCode(type));
            dto.setMessage(type.getName());
            dtoList.add(dto);
        }
        resultDto.setData(dtoList);
        return resultDto;
    }

}
